This will NOT work, since comments are parsed before the macro is expanded:
#ifdef DEBUG_ON
#define DBG
#else
#define DBG //
#endif
DBG cout << foo;
This is the simplest technique:
#ifdef DEBUG_ON
#define DBG(anything) anything
#else
#define DBG(anything) /*nothing*/
#endif
Then you can say:
//...
DBG(cout << "the value of foo is " << foo << '\n');
// ^-- ';' outside ()
Any commas in your 'DBG()' statement must be enclosed in a '()':
DBG(i=3, j=4); //<---- C-preprocessor will generate error message
DBG(i=3; j=4); //<---- ok
There are also more complicated techniques that use variable argument lists, but these are primarily useful for 'printf()' style (see question on the pros and cons of <iostream.h> as opposed to <stdio.h> for more).